package jdk8;

import java.util.Base64;

/**
 * @author oldliu
 * @since 1.0
 */
public class Base64Test {
    public static void main(String[] args) {
        //String->Base64
        String str="张良木是安庆第一帅哥";
        Base64.Encoder r= Base64.getEncoder();
        String  encode = r.encodeToString(str.getBytes());
        System.out.println(encode);
        //base64->String
        String str2="5byg6Imv5pyo5piv5a6J5bqG56ys5LiA5biF5ZOl";
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] b3 = decoder.decode(str2);
        String st2=new String(b3);
        System.out.println(st2);
    }
}
